package dfs_bfs.test78;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;

/**
 * 子集
 * @author code_yc
 * @version 1.0
 * @date 2020/7/9 9:55
 */
public class Solution1 {

    List<List<Integer>> res = new ArrayList<>();
    ArrayDeque<Integer> path = new ArrayDeque<>();

    public List<List<Integer>> subsets(int[] nums) {
        dfs(nums, 0);
        return res;
    }

    private void dfs(int[] nums, int c) {
        res.add(new ArrayList<>(path));

        for (int i = c; i < nums.length; i++) {
            path.addLast(nums[i]);
            dfs(nums, i + 1);
            path.pollLast();
        }
    }
}
